package com.lt.contract.service.impl;

import com.lt.contract.bean.BASE_DATA;
import com.lt.contract.bean.utils.SelectListVO;
import com.lt.contract.bean.utils.SelectVO;
import com.lt.contract.dao.BASE_DATAMapper;
import com.lt.contract.dao.NmDeptDao;
import com.lt.contract.dao.NmDeptStaffDao;
import com.lt.contract.service.CommonCService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class CommonCCServiceImpl implements CommonCService {

    @Autowired
    BASE_DATAMapper baseDataMapper;

    @Autowired
    NmDeptDao nmDeptDao;
    @Autowired
    NmDeptStaffDao nmDeptStaffDao;

    @Override
    public List<BASE_DATA> getBaseDataList(Map<String, Object> map) throws Exception {
        return baseDataMapper.getBaseDataList(map);
    }

    @Override
    public List<SelectListVO> getParentType(Map<String, Object> map) throws Exception {
        List<SelectListVO> listVOS =new ArrayList<>();
        map.put("selectId","400101");
        List<SelectVO> list = baseDataMapper.getParentType(map);
        for (int i = 0; i <list.size() ; i++) {
            if(i==0){
                map.put("selectId","300101");
            }else if(i==1){
                map.put("selectId","300201");
            }else if(i==2){
                map.put("selectId","300301");
            }
            SelectListVO selectListVO = new SelectListVO();
            selectListVO.setValue(list.get(i).getValue());
            selectListVO.setLabel(list.get(i).getLabel());
            List<SelectVO> list1 =baseDataMapper.getParentType(map);
            selectListVO.setChildren(list1);
            listVOS.add(selectListVO);
        }

        return listVOS;
    }

    @Override
    public List<SelectVO> queryAllDept() throws Exception {
        return nmDeptDao.queryAllDept();
    }

    @Override
    public List<SelectVO> queryAllDeptStaff(Map<String, Object> map) throws Exception {
        return nmDeptStaffDao.queryAllDeptStaff(map);
    }
}
